﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void YGRQCSM(DataSet db)
        {
            try
            {/*<GPGART,GPGVAR,GPGFARBE,GPSPPART,GPFBPART,GPZWPART,GABLO,GABLB,GABBUCHDAT,INQTY,PRODIN ,OUTQTY, ADJQTY--> */
                DataTable dtSoruce = db.Tables["GPDAT"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                exAgent.SetCellValue(3, idx++, "批号"); dtOutput.Columns.Add("GPSPPART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "质检单号"); dtOutput.Columns.Add("QOKORDER", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "品种"); dtOutput.Columns.Add("GPGART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色号"); dtOutput.Columns.Add("GPGFARBE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "回潮率"); dtOutput.Columns.Add("S001", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "马克隆值"); dtOutput.Columns.Add("S002", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "断裂比强度（cN/tex）"); dtOutput.Columns.Add("S003", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "上半部平均长度(mm)"); dtOutput.Columns.Add("S004", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "棉结（粒/g）"); dtOutput.Columns.Add("S005", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "颜色评语"); dtOutput.Columns.Add("S006", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "颜色级别"); dtOutput.Columns.Add("S007", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "颜色结论"); dtOutput.Columns.Add("S008", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "颜色均匀性评语"); dtOutput.Columns.Add("S009", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "颜色均匀性结论"); dtOutput.Columns.Add("S010", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色牢度级别"); dtOutput.Columns.Add("S011", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色牢度结论"); dtOutput.Columns.Add("S012", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "备注"); dtOutput.Columns.Add("S013", typeof(System.String)); 
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["GPSPPART"] = GetGB2312Value(row["GPSPPART"].ToString());
                    row["GPGFARBE"] = GetGB2312Value(row["GPGFARBE"].ToString());
                    row["S006"] = GetGB2312Value(row["S006"].ToString()); 
                    row["S008"] = GetGB2312Value(row["S008"].ToString());
                    row["S009"] = GetGB2312Value(row["S009"].ToString());
                    row["S010"] = GetGB2312Value(row["S010"].ToString());
                    row["S011"] = GetGB2312Value(row["S011"].ToString());
                    row["S012"] = GetGB2312Value(row["S012"].ToString());
                    row["S013"] = GetGB2312Value(row["S013"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1); 
                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1); 
                exAgent.BatchConvert2Number(4, 5, count + 3, 9);
                exAgent.SetCellValue(1, 1, "色棉质量");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}